package com.sj.common.dto.article;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import com.sj.common.dto.user.UserDto;
import com.sj.entity.Label;
import com.sj.entity.User;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: xiaoqi
 * Date: 2022-03-13
 * Time: 上午 10:33
 * Description: 文章类返回数据模型
 *
 * @author xiaoqi
 * @since 2022-03-13
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel("文章类返回数据模型")
public class ArticleDto implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty("文章id 自整张")
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    @ApiModelProperty("文章类型")
    private String type;

    @ApiModelProperty("文章标题")
    private String title;

    @ApiModelProperty("文章内容")
    private String content;

    @ApiModelProperty("文章浏览数量 默认0")
    private Integer browse;

    @ApiModelProperty("用户id")
    private Integer userId;

    @ApiModelProperty("文章首图")
    private String firstUrl;

    @ApiModelProperty("匿名 1 匿名 0 公开")
    private Boolean anonymity;

    @ApiModelProperty("是否仅自己可见？ 1 私密 0 公开")
    private Boolean isSecret;

    @ApiModelProperty("是否删除 1 删除 0 未删除")
    private Boolean del;

    @ApiModelProperty("标签列表")
    private List<Label> labelList;

    @ApiModelProperty("点赞数")
    private Long praiseNum;

    @ApiModelProperty("评论数")
    private Long commentNum;

    @ApiModelProperty("收藏数量")
    private Long collectNum;

    @ApiModelProperty("是否收藏")
    private Boolean isCollect;

    @ApiModelProperty("是否关注作者")
    private Boolean userIsAttention;

    @ApiModelProperty("用户信息")
    private UserDto user;

    @ApiModelProperty("创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    private LocalDateTime createTime;

    @ApiModelProperty("更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    private LocalDateTime updateTime;
}